package servlet;

import domain.BlackList;
import domain.UserClickCount;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/UserClickCountServlet")
public class UserClickCountServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.v->c:从页面读取参数，利用req对象
        //1.v->c:从页面读取参数，利用req对象
        UserClickCount userClickCount = new UserClickCount();

        int adid = Integer.parseInt(req.getParameter("adid"));

        userClickCount.setAdid(adid);

        req.getSession().setAttribute("ucc",userClickCount);

        System.out.println("ucc is ok");

        resp.setContentType("application/json;charset=utf-8");

        resp.sendRedirect("08.html");
    }
}
